package controller

import (
	"ollama-go/dto"
	"ollama-go/query"
	"ollama-go/service"

	"github.com/androidsr/sc-go/model"
	"github.com/androidsr/sc-go/sgin"
	"github.com/gin-gonic/gin"
)

func init() {
	sgin.AddRouter(TsStepLogController{
		tsStepLogService: service.NewTsStepLogService(),
	})
}

type TsStepLogController struct {
	tsStepLogService *service.TsStepLogService
}

// 查询
// @Router [get] [/tssteplog/:id]
func (m TsStepLogController) Get(c *gin.Context) any {
	id := c.Param("id")
	if id == "" {
		return model.NewFailDefault("ID不能为空")
	}
	return m.tsStepLogService.Get(id)
}

// 增加
// @Router [post] [/tssteplog]
func (m TsStepLogController) Save(c *gin.Context, dto *dto.TsStepLogDTO) any {
	dto.Id = ""
	return m.tsStepLogService.Save(dto)
}

// 修改
// @Router [put] [/tssteplog/edit]
func (m TsStepLogController) UpdateById(c *gin.Context, dto *dto.TsStepLogDTO) any {
	if dto.Id == "" {
		return model.NewFailDefault("ID不能为空")
	}
	return m.tsStepLogService.UpdateById(dto)

}

// 删除
// @Router [delete] [/tssteplog/:id]
func (m TsStepLogController) DeleteById(c *gin.Context) any {
	id := c.Param("id")
	if id == "" {
		return model.NewFailDefault("ID不能为空")
	}
	return m.tsStepLogService.DeleteById(id)
}

// 查询列表
// @Router [post] [/tssteplog/page]
func (m TsStepLogController) QueryPage(c *gin.Context, query *query.TsStepLogQueryDTO) any {
	return m.tsStepLogService.QueryPage(query)
}

// 分页下拉
// @Router [post] [/tssteplog/list]
func (m TsStepLogController) QuerySelect(c *gin.Context, query *model.SelectQueryDTO) any {
	return m.tsStepLogService.QueryList(query)
}
